﻿using Finbook.ConsoleApp.Services;
using Quartz;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace Finbook.ConsoleApp.Jobs
{
    public class TestJob
        : IJob
    {
        private readonly ITestService _testService;
        public TestJob()
        { }
        public TestJob(ITestService testService)
        {
            _testService = testService;
        }
        public async Task Execute(IJobExecutionContext context)
        {

            try
            {
                var dataMap = context.JobDetail.JobDataMap;
                var name = dataMap.GetString("name");
                await Task.Run(() => { Console.WriteLine($"//*******当前时间:{DateTime.Now},I will execute."); });
                var service = new TestService();
                service.SayHello(nameof(TestJob));
                _testService.SayHello(nameof(TestJob));
            }
            catch (Exception ex)
            {
                Console.WriteLine($"//******job:{ex.Message}");
            }
        }
    }
}
